package com.ruoyi.web.controller.app.service;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.web.exception.base.XException;
import com.ruoyi.im.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @ClassName AppIdInteractionService
 * @Description TODO
 * @Author tyc@yanyu
 * @Date 2018/12/29 0029 11:19
 **/
@Service
public class AppIdInteractionService {
    @Autowired
    private UserMapper userMapper;

    /**
     * 通过memberId查询IM id号
     * @param memberId
     * @return
     */
    public Object getIMId(String memberId) {
        if (StringUtils.isBlank(memberId)){
            throw new XException("用户ID号不能为空");
        }
        return userMapper.selectUserByMemberId(memberId);
    }

    /**
     * 通过IM id号查询memberId号
     * @param imId
     * @return
     */
    public Object getMemberId(String imId) {
        if (StringUtils.isBlank(imId)){
            throw new XException("IM ID号不能为空");
        }
        return userMapper.selectUserById(Long.valueOf(imId));
    }
}
